#include<iostream>
#include<vector>

using namespace std;

class Solution {
public:
    int maxArea(vector<int>& height) {
        int n = height.size() - 1;
        int str = 0, ptr = n;
        int max = 0;
        while (str < ptr)
        {
            int v = min(height[str], height[ptr]) * (ptr - str);
            if (max < v) max = v;
            if (height[str] < height[ptr]) str++;
            else ptr--;
        }
        return max;
    }
};


int main()
{
    Solution s;
    vector<int> height = {7,1,5,8,3,0,4,9,7,5,3,9};
    s.maxArea(height);
    return 0;
}